//
//  StatusRetweetedView.swift
//  微博项目
//
//  Created by zhaoyinpeng on 16/3/15.
//  Copyright © 2016年 zhaoyinpeng. All rights reserved.
//

import UIKit

class StatusRetweetedView: UIView {
    
    //.模型数据
    var retweetedStatus: Status? {
        didSet {
            //.绑定数据
            retweetedLabel.text = retweetedStatus?.text
            pictureView.imageURLs = retweetedStatus?.imageURLs
        }
    }
    
    
    
    //重写构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    private func setupUI() {
        backgroundColor = UIColor(white: 0.98, alpha: 1)
        addSubview(retweetedLabel)
        addSubview(pictureView)
        
        //设置约束
        retweetedLabel.snp_makeConstraints { (make) -> Void in
            make.left.top.equalTo(self).offset(StatusCellMargin)
            make.right.equalTo(self.snp_right).offset(-StatusCellMargin)
        }
        
        pictureView.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedLabel.snp_left)
            make.top.equalTo(retweetedLabel.snp_bottom).offset(StatusCellMargin)
            make.size.equalTo(CGSize(width: 100, height: 100))
        }
        
        //给转发微博的底部添加约束
        self.snp_makeConstraints { (make) -> Void in
            make.bottom.equalTo(pictureView.snp_bottom).offset(StatusCellMargin)
        }

    }
    
    
    //.懒加载视图
    private lazy var retweetedLabel: UILabel = UIFactory.labelFactory(UIColor.redColor(), fontSize: 14, text: "梦想还是要有的，万一实现了那", alignment: .Left)
    
    //.配图视图
    private lazy var pictureView: StatusPictureView = StatusPictureView()
}
